<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Linux常用软件安装 | 海内存知已，天涯若比邻</title><meta name="keywords" content="Linux,nginx,jdk,nacos,mysql,tomcat"><meta name="author" content="mowei"><meta name="copyright" content="mowei"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="01 jdk 安装1、rpm 下载地址 2、如果有安装 openjdk 则卸载（全部卸载！） 12345678910111213[root@kuangshen ~]# java -versionjava version &quot;1.8.0_121&quot;Java(TM) SE Runtime Environment (build 1.8.0_121-b13)Java HotSpot(TM)">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux常用软件安装">
<meta property="og:url" content="https://gitee.com/momomomowei/blog/linux/Linux%E5%B8%B8%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/index.html">
<meta property="og:site_name" content="海内存知已，天涯若比邻">
<meta property="og:description" content="01 jdk 安装1、rpm 下载地址 2、如果有安装 openjdk 则卸载（全部卸载！） 12345678910111213[root@kuangshen ~]# java -versionjava version &quot;1.8.0_121&quot;Java(TM) SE Runtime Environment (build 1.8.0_121-b13)Java HotSpot(TM)">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/momomomowei/images/linux.png">
<meta property="article:published_time" content="2021-09-16T11:43:06.000Z">
<meta property="article:modified_time" content="2024-04-21T07:24:14.397Z">
<meta property="article:author" content="mowei">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="nginx">
<meta property="article:tag" content="jdk">
<meta property="article:tag" content="nacos">
<meta property="article:tag" content="mysql">
<meta property="article:tag" content="tomcat">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/momomomowei/images/linux.png"><link rel="shortcut icon" href="/media/favicon.png"><link rel="canonical" href="https://gitee.com/momomomowei/blog/linux/Linux%E5%B8%B8%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Linux常用软件安装',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-04-21 15:24:14'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    document.addEventListener('pjax:complete', detectApple)})(window)</script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/media/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">41</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">29</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">7</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 目录</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/images/linux.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">海内存知已，天涯若比邻</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 目录</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Linux常用软件安装</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-09-16T11:43:06.000Z" title="发表于 2021-09-16 19:43:06">2021-09-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-21T07:24:14.397Z" title="更新于 2024-04-21 15:24:14">2024-04-21</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Linux/">Linux</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>12分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Linux常用软件安装"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="01-jdk-安装"><a href="#01-jdk-安装" class="headerlink" title="01 jdk 安装"></a>01 jdk 安装</h1><p>1、<a target="_blank" rel="noopener" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">rpm 下载地址</a></p>
<p>2、如果有安装 openjdk 则卸载（全部卸载！）</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[root@kuangshen ~]# java -version</span><br><span class="line">java version &quot;1.8.0_121&quot;</span><br><span class="line">Java(TM) SE Runtime Environment (build 1.8.0_121-b13)</span><br><span class="line">Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">检查，全部卸载</span></span><br><span class="line">[root@kuangshen ~]# rpm -qa|grep jdk</span><br><span class="line">jdk1.8.0_121-1.8.0_121-fcs.x86_64</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">卸载 -e --nodeps 强制删除</span></span><br><span class="line">[root@kuangshen ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64</span><br><span class="line">[root@kuangshen ~]# java -version</span><br><span class="line">-bash: /usr/bin/java: No such file or directory  # OK</span><br></pre></td></tr></table></figure>
<p>3、安装 JDK</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装java rpm</span></span><br><span class="line">rpm -ivh jdk-8u221-linux-x64.rpm</span><br></pre></td></tr></table></figure>
<p>4、配置环境变量</p>
<blockquote>
<p>获取 JAVA_HOME :</p>
<p>​ which java</p>
<p>​ ll /usr/bin/java</p>
<p>​ ll /etc/alternatives/java</p>
<p>结果：/etc/alternatives/java -&gt; /usr/java/jdk1.8.0_291-amd64/bin/java</p>
<p>JAVA_HOME 就是 <code>/usr/java/jdk1.8.0_291-amd64</code></p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装完成后配置环境变量 文件：/etc/profile</span></span><br><span class="line">export JAVA_HOME=/usr/java/jdk1.8.0_221-amd64</span><br><span class="line">export CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib</span><br><span class="line">export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">让新增的环境变量生效！</span></span><br><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
<p>5、测试安装成功</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">测试 java -version</span></span><br><span class="line">[root@localhost java]# java -version</span><br><span class="line">java version &quot;1.8.0_221&quot;</span><br><span class="line">Java(TM) SE Runtime Environment (build 1.8.0_221-b11)</span><br><span class="line">Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)</span><br></pre></td></tr></table></figure>
<h1 id="02-nacos-安装"><a href="#02-nacos-安装" class="headerlink" title="02 nacos 安装"></a>02 nacos 安装</h1><h2 id="1、安装和启动"><a href="#1、安装和启动" class="headerlink" title="1、安装和启动"></a>1、安装和启动</h2><blockquote>
<p>注意要先安装 <code>jdk</code>，并且配置好 <code>JAVA_HOME</code></p>
<p>使用 <code>env</code> 或者 <code>echo $JAVA_HOME</code> 查看是否配置</p>
</blockquote>
<p>1、将文件上传到 <code>/usr/local</code> 目录</p>
<p>2、解压得到 <code>nacos</code> 文件夹</p>
<p>3、进入 <code>nacos/bin</code> 目录启动 <code>nacos</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">进入目录</span></span><br><span class="line">cd /usr/local/nacos/bin/</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">启动单机版</span></span><br><span class="line">./startup.sh -m standalone</span><br></pre></td></tr></table></figure>
<p>4、查看防火墙配置，需要开放 <code>8848</code> 端口</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看firewall的状态</span></span><br><span class="line">firewall-cmd --state</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看防火墙全部的信息</span></span><br><span class="line">firewall-cmd --list-all</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看防火墙已开通的端口</span></span><br><span class="line">firewall-cmd --list-port</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开放 8848 端口</span></span><br><span class="line">firewall-cmd --zone=public --add-port=8848/tcp --permanent</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">移去 8848 端口</span></span><br><span class="line">firewall-cmd --zone=public --remove-port=8848/tcp --permanent</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重新加载防火墙配置</span></span><br><span class="line">firewall-cmd --reload</span><br></pre></td></tr></table></figure>
<blockquote>
<p>打开浏览器即可访问 ，路径：<code>http://服务器地址:8848/nacos</code></p>
</blockquote>
<h2 id="2、配置开机启动"><a href="#2、配置开机启动" class="headerlink" title="2、配置开机启动"></a>2、配置开机启动</h2><p>1、进入 <code>/lib/systemd/system</code> 目录, 创建 <code>nacos.service</code> 文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /lib/systemd/system</span><br><span class="line"></span><br><span class="line"><span class="built_in">touch</span> nacos.service</span><br></pre></td></tr></table></figure>
<p>2、编辑 <code>nacos.service</code> 文件, 增加如下信息</p>
<blockquote>
<p><code>nacos</code> 路径替换成自己的路径即可</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">[Unit]</span><br><span class="line">Description=nacos</span><br><span class="line">After=network.target</span><br><span class="line"></span><br><span class="line">[Service]</span><br><span class="line">Type=forking</span><br><span class="line">ExecStart=/usr/local/nacos/bin/startup.sh -m standalone</span><br><span class="line">ExecReload=/usr/local/nacos/bin/shutdown.sh</span><br><span class="line">ExecStop=/usr/local/nacos/bin/shutdown.sh</span><br><span class="line">PrivateTmp=true</span><br><span class="line"></span><br><span class="line">[Install]</span><br><span class="line">WantedBy=multi-user.target</span><br></pre></td></tr></table></figure>
<p>3、编辑 <code>nacos/bin</code> 目录下的 <code>startup.sh</code>, 修改 <code>JAVA_HOME</code> 的路径, 注释其他三行</p>
<blockquote>
<p><code>JAVA_HOME</code> 为 <code>env</code> 输出的 目录，注意！</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[ ! -e &quot;$JAVA_HOME/bin/java&quot; ] &amp;&amp; JAVA_HOME=/usr/java/jdk1.8.0_291-amd64</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">[ ! -e <span class="string">&quot;<span class="variable">$JAVA_HOME</span>/bin/java&quot;</span> ] &amp;&amp; JAVA_HOME=/usr/java</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">[ ! -e <span class="string">&quot;<span class="variable">$JAVA_HOME</span>/bin/java&quot;</span> ] &amp;&amp; JAVA_HOME=/opt/taobao/java</span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">[ ! -e <span class="string">&quot;<span class="variable">$JAVA_HOME</span>/bin/java&quot;</span> ] &amp;&amp; <span class="built_in">unset</span> JAVA_HOME</span></span><br></pre></td></tr></table></figure>
<p>4、执行以下命令来设置开机启动</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重新加载所有service服务</span></span><br><span class="line"> systemctl daemon-reload</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开机启动nacos.service</span></span><br><span class="line">systemctl enable nacos.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看该service是否开机启用</span></span><br><span class="line">systemctl is-enabled nacos.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">启动该服务</span></span><br><span class="line">systemctl start nacos.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看该服务状态</span></span><br><span class="line">systemctl status nacos.service</span><br></pre></td></tr></table></figure>
<h2 id="3、切换-mysql-保存数据"><a href="#3、切换-mysql-保存数据" class="headerlink" title="3、切换 mysql 保存数据"></a>3、切换 mysql 保存数据</h2><blockquote>
<p>需要先保证 已经安装好 mysql</p>
</blockquote>
<p>1、在安装目录 <code>nacos/conf</code>目录下找到 <code>nacos-mysql.sql</code> 脚本，使用 <code>mysql</code> 导入</p>
<p>2、配置 <code>nacos/conf</code> 下 <code>application.properties</code> ，添加以下配置</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">spring.datasource.platform=mysql</span><br><span class="line"></span><br><span class="line">db.num=1</span><br><span class="line">db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&amp;connectTimeout=1000&amp;socketTimeout=3000&amp;autoReconnect=true</span><br><span class="line">db.user=root</span><br><span class="line">db.password=123456</span><br></pre></td></tr></table></figure>
<p>3、重新启动 Nacos，如果记录是全新的，说明成功！</p>
<pre><code>systemctl restart nacos
</code></pre><h1 id="03-mysql-安装-5-x-8-x"><a href="#03-mysql-安装-5-x-8-x" class="headerlink" title="03 mysql 安装(5.x/8.x)"></a>03 mysql 安装(5.x/8.x)</h1><h2 id="1、安装"><a href="#1、安装" class="headerlink" title="1、安装"></a>1、安装</h2><p>1、<a target="_blank" rel="noopener" href="https://dev.mysql.com/downloads/mysql/">下载 mysql 安装包</a></p>
<blockquote>
<p>选择 <code>Linux - Generic</code> 版本，如 <code>Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive</code></p>
</blockquote>
<p>2、安装包上传至服务器 <code>/usr/local</code></p>
<p>3、解压并移动文件到 <code>/usr/local/mysql/</code>，看格式选择解压命令，比如：</p>
<blockquote>
<p>tar -xvf mysql-8.0.11-linux-glibc2.12-x86_64.tar<br>tar -zxvf mysql-8.0.11-linux-glibc2.12-x86_64.tar.gz</p>
</blockquote>
<p>4、用户组设置</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">增加用户组 mysql</span></span><br><span class="line">sudo groupadd mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">在用户组下增加用户 mysql</span></span><br><span class="line">sudo useradd -r -g mysql mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">检查用户组、用户是否存在</span></span><br><span class="line">groups mysql</span><br></pre></td></tr></table></figure>
<blockquote>
<p>若存在则显示 <code>mysql : mysql</code> ；若不存在，则显示 <code>groups: mysql: No such user</code></p>
</blockquote>
<p>5、将安装目录 <code>/usr/local/mysql/</code> 的所有者及所属组改为 <code>mysql</code></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chown -R mysql:mysql /usr/local/mysql/</span><br></pre></td></tr></table></figure>
<p>6、创建配置文件 <code>/etc/my.cnf</code></p>
<blockquote>
<p>如果文件已经存在，请先备份后再操作！ cp my.cnf my.cnf.bak</p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">touch /etc/my.cnf</span><br><span class="line">vim /etc/my.cnf</span><br></pre></td></tr></table></figure>
<p>7、增加配置，设置编码格式及忽略大小写</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[mysqld]</span><br><span class="line">basedir=/usr/local/mysql</span><br><span class="line">datadir=/usr/local/mysql/data</span><br><span class="line">port=3306</span><br><span class="line">socket=/tmp/mysql.sock</span><br><span class="line">character_set_server=utf8</span><br><span class="line">lower_case_table_names=1</span><br><span class="line">log-error=/usr/local/mysql/data/mysql.log</span><br><span class="line">pid-file=/usr/local/mysql/data/mysql.pid</span><br><span class="line">[mysql]</span><br><span class="line">default-character-set=utf8</span><br></pre></td></tr></table></figure>
<p>8、在 <code>/usr/local/mysql/</code> 目录下创建一个 <code>data</code> 文件夹</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/mysql/</span><br><span class="line">mkdir data</span><br></pre></td></tr></table></figure>
<p>9、进入 <code>/usr/local/mysql/bin</code>，开始初始化</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/mysql/bin</span><br><span class="line"></span><br><span class="line">./mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/</span><br></pre></td></tr></table></figure>
<blockquote>
<p>若出现错误对应安装以下软件包后重试：</p>
<p><code>-bash: /usr/local/mysql/bin/mysqld: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录</code><br>yum install glibc.i686 -y</p>
<p><code>mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory</code> &gt; #yum install libaio -y<br>#yum -y install numactl -y<br>yum install libaio.so.1 -y</p>
<p><code>mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory</code><br>yum install libnuma.so.1 -y</p>
<p><code>mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory</code><br>yum install libtinfo.so.5 -y</p>
</blockquote>
<p>10、将 <code>mysql</code> 加入到可控制启动服务的文件夹内，并命名 <code>mysql</code>（service 可控制的服务名）</p>
<blockquote>
<p>目的：可用 <code>service mysql start</code> 命令来控制启动 <code>mysql</code></p>
</blockquote>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">cd /usr/local/mysql/support-files</span><br><span class="line">cp mysql.server /etc/init.d/mysql</span><br></pre></td></tr></table></figure>
<p>11、配置环境变量</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/profile</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">添加以下内容</span></span><br><span class="line">export MYSQL_HOME=/usr/local/mysql</span><br><span class="line">export PATH=$PATH:$MYSQL_HOME/bin</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">立即生效</span></span><br><span class="line">source /etc/profile</span><br></pre></td></tr></table></figure>
<p>12、启动并登录 mysql</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">启动 mysql</span></span><br><span class="line">service mysql start</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">获取初始密码</span></span><br><span class="line">cat /usr/local/mysql/data/mysql.log | grep password</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">登录 mysql</span></span><br><span class="line">mysql -u root -p</span><br></pre></td></tr></table></figure>
<p>13、修改初始密码</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#设置密码</span><br><span class="line">#alter user root identified by &#x27;123456&#x27;;</span><br><span class="line">#user()可以获取当前用户名（推荐使用这个）</span><br><span class="line">alter user user() identified by &#x27;123456&#x27;;</span><br><span class="line">flush privileges;</span><br></pre></td></tr></table></figure>
<p>14、开放远程链接</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">use mysql;</span><br><span class="line">select host,user from user;</span><br><span class="line">update user set host = &#x27;%&#x27; where user = &#x27;root&#x27;;</span><br><span class="line">flush privileges;</span><br></pre></td></tr></table></figure>
<p>15、开放防火墙</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">查看防火墙规则</span></span><br><span class="line">firewall-cmd --list-all    # 查看全部信息</span><br><span class="line">firewall-cmd --list-ports  # 只看端口信息</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">开启端口</span></span><br><span class="line">firewall-cmd --zone=public --add-port=3306/tcp --permanent</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重新加载防火墙配置</span></span><br><span class="line">firewall-cmd --reload</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重启防火墙</span></span><br><span class="line">systemctl restart firewalld.service</span><br></pre></td></tr></table></figure>
<p>16、设置开机启动</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重新加载所有service服务</span></span><br><span class="line"> systemctl daemon-reload</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开机启动nacos.service</span></span><br><span class="line">systemctl enable mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看该service是否开机启用</span></span><br><span class="line">systemctl is-enabled mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">启动该服务</span></span><br><span class="line">systemctl start mysql</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">查看该服务状态</span></span><br><span class="line">systemctl status mysql</span><br></pre></td></tr></table></figure>
<h2 id="2、备份（导出）"><a href="#2、备份（导出）" class="headerlink" title="2、备份（导出）"></a>2、备份（导出）</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">全量备份（数据+结构）：</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">mysqldump -uroot -p123456 -A &gt; 备份文件路径</span></span><br><span class="line"></span><br><span class="line">指定库备份（数据+结构）：</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">mysqldump -uroot -p123456 库名 &gt; 备份文件路径</span></span><br><span class="line"></span><br><span class="line">多个库备份（数据+结构）：</span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">mysqldump -uroot -p123456 --databases db1 db2 &gt;  备份文件路径</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>案例：备份整个库</p>
<p>mysqldump -uroot -pqhabOfhlluB9 -A &gt; /root/sql_201804061609.sql</p>
</blockquote>
<h2 id="3、还原（导入）"><a href="#3、还原（导入）" class="headerlink" title="3、还原（导入）"></a>3、还原（导入）</h2><p>1.还原全部数据库:</p>
<p>(1) mysql 命令行：mysql&gt; source 备份文件路径<br>(2) 系统命令行： #mysql -uroot -p123456 &lt; 备份文件路径</p>
<p>2.还原单个数据库(需指定数据库)</p>
<p>(1) mysql&gt; use 库名<br>mysql&gt; source 备份文件路径<br>(2) #mysql -uroot -p123456 库名 &lt; 备份文件路径</p>
<p>3.还原单个数据库的多个表(需指定数据库)</p>
<p>(1) mysql&gt; use 库名<br>mysql&gt; source 备份文件路径<br>(2) mysql -uroot -p123456 库名 &lt; 备份文件路径</p>
<p>4.还原多个数据库，（一个备份文件里有多个数据库的备份，此时不需要指定数据库）</p>
<p>(1) mysql 命令行：mysql&gt; source 备份文件路径<br>(2) 系统命令行： mysql -uroot -p123456 &lt; 备份文件路径</p>
<h1 id="04-Nginx-安装"><a href="#04-Nginx-安装" class="headerlink" title="04 Nginx 安装"></a>04 Nginx 安装</h1><blockquote>
<p>关于版本：</p>
<p><strong>Nginx 开源版</strong> &gt; <a target="_blank" rel="noopener" href="http://nginx.org/">http://nginx.org/</a></p>
<p><strong>Nginx plus 商业版</strong> &gt; <a target="_blank" rel="noopener" href="https://www.nginx.com">https://www.nginx.com</a></p>
<p><strong>openresty</strong> &gt; <a target="_blank" rel="noopener" href="http://openresty.org/cn/">http://openresty.org/cn/</a></p>
<p><strong>Tengine</strong> &gt; <a target="_blank" rel="noopener" href="http://tengine.taobao.org/">http://tengine.taobao.org/</a></p>
</blockquote>
<p>1、下载上传文件</p>
<p>2、编译安装</p>
<pre><code>./configure --prefix=/usr/local/nginx
make
make install
</code></pre><blockquote>
<p>如果出现警告，安装依赖</p>
<p>yum install -y gcc</p>
<p>yum install -y pcre pcre-devel</p>
<p>yum install -y zlib zlib-devel</p>
</blockquote>
<p>3、启动 Nginx</p>
<p>进入安装好的目录<code>/usr/local/nginx/sbin</code></p>
<pre><code>./nginx             启动
./nginx -s stop     快速停止
./nginx -s quit     优雅关闭，在退出前完成已经接受的连接请求
./nginx -s reload     重新加载配置
</code></pre><blockquote>
<p>#关闭防火墙<br>systemctl stop firewalld.service</p>
<p>#禁止防火墙开机启动<br>systemctl disable firewalld.service</p>
<p>#放行端口<br>firewall-cmd —zone=public —add-port=80/tcp —permanent</p>
<p>#重启防火墙<br>firewall-cmd —reload</p>
</blockquote>
<p>4、安装成系统服务</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">创建服务脚本</span></span><br><span class="line">vi /usr/lib/systemd/system/nginx.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">服务脚本内容（注意安装目录是否正确）</span></span><br><span class="line">[Unit]</span><br><span class="line">Description=nginx - web server</span><br><span class="line">After=network.target remote-fs.target nss-lookup.target</span><br><span class="line">[Service]</span><br><span class="line">Type=forking</span><br><span class="line">PIDFile=/usr/local/nginx/logs/nginx.pid</span><br><span class="line">ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf</span><br><span class="line">ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</span><br><span class="line">ExecReload=/usr/local/nginx/sbin/nginx -s reload</span><br><span class="line">ExecStop=/usr/local/nginx/sbin/nginx -s stop</span><br><span class="line">ExecQuit=/usr/local/nginx/sbin/nginx -s quit</span><br><span class="line">PrivateTmp=true</span><br><span class="line"></span><br><span class="line">[Install]</span><br><span class="line">WantedBy=multi-user.target</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">重新加载系统服务</span></span><br><span class="line">systemctl daemon-reload</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">启动服务</span></span><br><span class="line">systemctl start nginx.service</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_">#</span><span class="language-bash">开机启动</span></span><br><span class="line">systemctl enable nginx.service</span><br></pre></td></tr></table></figure>
<h1 id="05-Tomcat-安装"><a href="#05-Tomcat-安装" class="headerlink" title="05 Tomcat 安装"></a>05 Tomcat 安装</h1><p>1、安装好了 Java 环境后我们可以测试下 Tomcat！准备好 Tomcat 的安装包！</p>
<p>2、将文件移动到/usr/tomcat/下，并解压！</p>
<pre><code>[root@kuangshen kuangshen]# mv apache-tomcat-9.0.22.tar.gz /usr
[root@kuangshen kuangshen]# cd /usr
[root@kuangshen usr]# ls
apache-tomcat-9.0.22.tar.gz
[root@kuangshen usr]# tar -zxvf apache-tomcat-9.0.22.tar.gz   # 解压
</code></pre><p>3、运行 Tomcat，进入 bin 目录，和我们以前在 Windows 下看的都是一样的</p>
<pre><code># 执行：startup.sh --&gt;启动tomcat
# 执行：shutdown.sh --&gt;关闭tomcat
./startup.sh
./shutdown.sh
</code></pre><p>4、确保 Linux 的防火墙端口是开启的，如果是阿里云，需要保证阿里云的安全组策略是开放的！</p>
<pre><code># 查看firewall服务状态
systemctl status firewalld

# 开启、重启、关闭、firewalld.service服务
# 开启
service firewalld start
# 重启
service firewalld restart
# 关闭
service firewalld stop

# 查看防火墙规则
firewall-cmd --list-all    # 查看全部信息
firewall-cmd --list-ports  # 只看端口信息

# 开启端口
开端口命令：firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙：systemctl restart firewalld.service

命令含义：
--zone #作用域
--add-port=80/tcp  #添加端口，格式为：端口/通讯协议
--permanent   #永久生效，没有此参数重启后失效
</code></pre><h1 id="06-Docker-安装"><a href="#06-Docker-安装" class="headerlink" title="06 Docker 安装"></a>06 Docker 安装</h1><blockquote>
<p>基于 CentOS 7 安装</p>
</blockquote>
<ol>
<li><p>官网安装参考手册：<a target="_blank" rel="noopener" href="https://docs.docker.com/install/linux/docker-ce/centos/">https://docs.docker.com/install/linux/docker-ce/centos/</a></p>
</li>
<li><p>确定你是 CentOS7 及以上版本</p>
<pre><code>[root@192 Desktop]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
</code></pre></li>
<li><p>yum 安装 gcc 相关（需要确保 虚拟机可以上外网 ）</p>
<pre><code>yum -y install gcc
yum -y install gcc-c++
</code></pre></li>
<li><p>卸载旧版本</p>
<pre><code>yum -y remove docker docker-common docker-selinux docker-engine
# 官网版本
yum remove docker \
          docker-client \
          docker-client-latest \
          docker-common \
          docker-latest \
          docker-latest-logrotate \
          docker-logrotate \
          docker-engine
</code></pre></li>
<li><p>安装需要的软件包</p>
<pre><code>yum install -y yum-utils device-mapper-persistent-data lvm2
</code></pre></li>
<li><p>设置 stable 镜像仓库</p>
<pre><code># 错误
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 报错
[Errno 14] curl#35 - TCP connection reset by peer
[Errno 12] curl#35 - Timeout

# 正确推荐使用国内的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
</code></pre></li>
<li><p>更新 yum 软件包索引</p>
<pre><code>yum makecache fast
</code></pre></li>
<li><p>安装 Docker CE</p>
<pre><code>yum -y install docker-ce docker-ce-cli containerd.io
</code></pre></li>
<li><p>启动 docker</p>
<pre><code>systemctl start docker
</code></pre></li>
<li><p>测试</p>
<pre><code>docker version

docker run hello-world

docker images
</code></pre></li>
</ol>
</article><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Linux/">Linux</a><a class="post-meta__tags" href="/tags/nginx/">nginx</a><a class="post-meta__tags" href="/tags/jdk/">jdk</a><a class="post-meta__tags" href="/tags/nacos/">nacos</a><a class="post-meta__tags" href="/tags/mysql/">mysql</a><a class="post-meta__tags" href="/tags/tomcat/">tomcat</a></div><div class="post_share"></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-full"><a href="/blog/linux/centos7%20%E5%9B%BA%E5%AE%9Aip%E5%9C%B0%E5%9D%80/"><img class="prev-cover" src= "" data-lazy-src="/images/centos.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">centos7 固定ip地址</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/linux/100 Redis Linux环境安装/" title="Redis Linux 环境安装"><img class="cover" src= "" data-lazy-src="/images/redis.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-21</div><div class="title">Redis Linux 环境安装</div></div></a></div><div><a href="/blog/linux/Linux/" title="Linux 常用"><img class="cover" src= "" data-lazy-src="/images/linux.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-16</div><div class="title">Linux 常用</div></div></a></div><div><a href="/blog/linux/centos7 固定ip地址/" title="centos7 固定ip地址"><img class="cover" src= "" data-lazy-src="/images/centos.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-09-16</div><div class="title">centos7 固定ip地址</div></div></a></div><div><a href="/blog/linux/vim常用操作/" title="vim常用操作"><img class="cover" src= "" data-lazy-src="/images/vim.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-21</div><div class="title">vim常用操作</div></div></a></div><div><a href="/blog/nginx/Nginx 配置详解 /" title="Nginx 配置详解"><img class="cover" src= "" data-lazy-src="/images/nginx.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-03-18</div><div class="title">Nginx 配置详解</div></div></a></div><div><a href="/blog/nginx/Nginx安装配置/" title="Nginx安装配置"><img class="cover" src= "" data-lazy-src="/images/nginx.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-03-18</div><div class="title">Nginx安装配置</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">一切解释权归本咸鱼所有</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#01-jdk-%E5%AE%89%E8%A3%85"><span class="toc-number">1.</span> <span class="toc-text">01 jdk 安装</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#02-nacos-%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">02 nacos 安装</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%AE%89%E8%A3%85%E5%92%8C%E5%90%AF%E5%8A%A8"><span class="toc-number">2.1.</span> <span class="toc-text">1、安装和启动</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E9%85%8D%E7%BD%AE%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8"><span class="toc-number">2.2.</span> <span class="toc-text">2、配置开机启动</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E5%88%87%E6%8D%A2-mysql-%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE"><span class="toc-number">2.3.</span> <span class="toc-text">3、切换 mysql 保存数据</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#03-mysql-%E5%AE%89%E8%A3%85-5-x-8-x"><span class="toc-number">3.</span> <span class="toc-text">03 mysql 安装(5.x&#x2F;8.x)</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1%E3%80%81%E5%AE%89%E8%A3%85"><span class="toc-number">3.1.</span> <span class="toc-text">1、安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2%E3%80%81%E5%A4%87%E4%BB%BD%EF%BC%88%E5%AF%BC%E5%87%BA%EF%BC%89"><span class="toc-number">3.2.</span> <span class="toc-text">2、备份（导出）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3%E3%80%81%E8%BF%98%E5%8E%9F%EF%BC%88%E5%AF%BC%E5%85%A5%EF%BC%89"><span class="toc-number">3.3.</span> <span class="toc-text">3、还原（导入）</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#04-Nginx-%E5%AE%89%E8%A3%85"><span class="toc-number">4.</span> <span class="toc-text">04 Nginx 安装</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#05-Tomcat-%E5%AE%89%E8%A3%85"><span class="toc-number">5.</span> <span class="toc-text">05 Tomcat 安装</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#06-Docker-%E5%AE%89%E8%A3%85"><span class="toc-number">6.</span> <span class="toc-text">06 Docker 安装</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/java/01%20Spring%20Security%20&amp;%20oauth2/" title="Spring Security &amp; Oauth2"><img src= "" data-lazy-src="/images/spring-security.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Spring Security &amp; Oauth2"/></a><div class="content"><a class="title" href="/blog/java/01%20Spring%20Security%20&amp;%20oauth2/" title="Spring Security &amp; Oauth2">Spring Security &amp; Oauth2</a><time datetime="2024-04-25T07:24:45.000Z" title="发表于 2024-04-25 15:24:45">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/02%20JWT%E5%B7%A5%E5%85%B7%E7%B1%BB/" title="JWT工具类"><img src= "" data-lazy-src="/images/jwt.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="JWT工具类"/></a><div class="content"><a class="title" href="/blog/java/02%20JWT%E5%B7%A5%E5%85%B7%E7%B1%BB/" title="JWT工具类">JWT工具类</a><time datetime="2024-04-25T07:24:45.000Z" title="发表于 2024-04-25 15:24:45">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/00%20Security%20%E9%9B%86%E6%88%90%E7%A4%BA%E4%BE%8B/" title="SpringSecurity 集成示例"><img src= "" data-lazy-src="/images/spring-security.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="SpringSecurity 集成示例"/></a><div class="content"><a class="title" href="/blog/java/00%20Security%20%E9%9B%86%E6%88%90%E7%A4%BA%E4%BE%8B/" title="SpringSecurity 集成示例">SpringSecurity 集成示例</a><time datetime="2024-04-25T07:24:43.000Z" title="发表于 2024-04-25 15:24:43">2024-04-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/101%20Mybatis-plus%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="MybatisPlus 快速集成"><img src= "" data-lazy-src="/images/mybatis-plus.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="MybatisPlus 快速集成"/></a><div class="content"><a class="title" href="/blog/java/101%20Mybatis-plus%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="MybatisPlus 快速集成">MybatisPlus 快速集成</a><time datetime="2024-04-21T07:39:43.000Z" title="发表于 2024-04-21 15:39:43">2024-04-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/java/10%20Mybatis%20%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="Mybatis 快速集成"><img src= "" data-lazy-src="/images/mybaits.jpeg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Mybatis 快速集成"/></a><div class="content"><a class="title" href="/blog/java/10%20Mybatis%20%E5%BF%AB%E9%80%9F%E9%9B%86%E6%88%90/" title="Mybatis 快速集成">Mybatis 快速集成</a><time datetime="2024-04-21T07:24:43.000Z" title="发表于 2024-04-21 15:24:43">2024-04-21</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By mowei</div><div class="footer_custom_text">海内存知已，天涯若比邻</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      true && mermaid.init()
    })
  }
}</script></div><div class="aplayer no-destroy" data-id="9385310356" data-server="netease" data-type="playlist" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-preload="none" data-autoplay="true" muted></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script defer="defer" id="fluttering_ribbon" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = [
  'title',
  '#config-diff',
  '#body-wrap',
  '#rightside-config-hide',
  '#rightside-config-show',
  '.js-pjax'
]

if (false) {
  pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]')
}

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.removeEventListener('scroll', window.tocScrollFn)
  window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // Analytics
  if (false) {
    MtaH5.pgv()
  }

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src="/live2d_models/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2d_models/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2d_models/assets/wanko.model.json"},"display":{"position":"left","width":100,"height":150,"hOffset":-10,"vOffset":40},"mobile":{"show":true},"react":{"opacity":0.7},"log":false});</script></body></html>